package com.vanzo.ui;

import android.app.Application;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.vanzo.Tpplication;
import com.vanzo.instruction.Instruction;
import com.vanzo.util.LogUtil;

/**
 * Created by yaofang on 2018/3/5.
 * fragment的基类
 */

public abstract class BaseFragment2 extends Fragment {

    private View root;
    protected Tpplication tpplication;
    protected Instruction instruction;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        root = inflater.inflate(getFragmentLayoutId(), container, false);
        tpplication = (Tpplication) getActivity().getApplication();
        instruction = tpplication.getInstruction();
        initView();
        initListener();
        initData();
        return root;
    }

    protected View getRoot() {
        return root;
    }

    protected abstract int getFragmentLayoutId();

    protected abstract void initView();

    protected abstract void initListener();

    protected abstract void initData();

    @Override
    public void onResume() {
        super.onResume();
        LogUtil.put(this, "onResume", LogUtil.WARN);
    }
}
